﻿/*include:js\declare*/
//验证图片	<img verifyimage="{Width:80,Height:20,ButtonId:'YYY'}" id="XXX" />
//fastCSharp.VerifyImages.XXX
(function(){
var VerifyImage=function()
	{
	this.GetArgument(arguments[0],{Id:null,Event:null,Width:null,Height:null,ButtonId:null,OnClick:null});
	this.OnClick=fastCSharp.Event().Add(this.OnClick);
	this.Start(this.Event||{IsGetOnly:1});
	};
(fastCSharp.Functions.VerifyImage=VerifyImage).Inherit(fastCSharp.BaseFunction,{
Start:function(Event)
	{
	if(!Event.IsGetOnly)
		{
		var Element=fastCSharp.$Id(this.Id),Input=Element.Element();
		if(Input!=this.Element)
			{
			this.Element=Input;
			var Element=this.$Id(this.Id).Set('alt','验证码').Set('border',0);
			if(this.Width)	Element.Set('width',this.Width);
			if(this.Height)	Element.Set('height',this.Height);
			this.$Id(this.ButtonId).Cursor('pointer').AddEvent('click',fastCSharp.ThisFunction(this,this.ClickButton));
			this.Show(0);
			}
		}
	},
ClickButton:function()
	{
	this.Show(1);
	this.OnClick();
	},
Show:function(IsRefresh)
	{
	var Verify=IsRefresh?null:fastCSharp.Cookie.Read('VerifyImage');
	if(!Verify)	Verify=(new Date).getTime();
	fastCSharp.Cookie.Write({Name:'VerifyImage',Value:Verify,Expires:(new Date).AddMinutes(20)});
	this.$Id(this.Id).Set('src','/verifyImage?t='+Verify).Display(1);
	},
Clear:function()
	{
	fastCSharp.Cookie.Write({Name:'VerifyImage'});
	}
		});
new fastCSharp.Declare('VerifyImage','mouseover','AttributeName');
})();